const app = getApp();
Component({
  pageLifetimes: {
    show() {
      let that = this;
      let openId = app.globalData.openId;
      if (typeof this.getTabBar === 'function' &&
        this.getTabBar()) {
        this.getTabBar().setData({
          selected: 1
        })
      }
      that.getUserData(that,openId)
    },
  },
  data:{
    screenHeight:app.globalData.screenHeight
  },
  methods:{
    getUserData (that, openId) {
      app.globalData.wxRequest.requestGet('volunteer/getUserDetail.do', { openId: openId }).then(res => {
        // console.log(res);
        if(res.code == '201'){
          wx.showToast({
            title: res.msg,
            icon:'error'
          })
        }
        that.setData({
          userInfo: res.data,
        })
      }).catch(err => {
        wx.showToast({
          title: '请求失败',
          icon: 'error'
        })
      })
    },
    likemajor(){
      wx.navigateTo({
        url: '/pages/bar/me/likemajor/likemajor',
      })
    },
    aboutus(){
      wx.navigateTo({
        url: '/pages/bar/me/aboutus/aboutus',
      })
    },
    attentionSchool(){
      wx.navigateTo({
        url: '/pages/bar/me/attentionSchool/attentionSchool',
      })
    },
    likemajor(){
      wx.navigateTo({
        url: '/pages/bar/me/likemajor/likemajor',
      })
    },
    feedback(){
      wx.navigateTo({
        url: '/pages/bar/me/feedback/feedback',
      })
    },
    myvolunteerList(e){
      if(this.data.userInfo==null){
        wx.showModal({
          title: '提示',
          content: '请先填写个人信息',
          showCancel:false,
          success (res) {
            if (res.confirm) {
              return
            } 
          }
        })
      }else{
        wx.navigateTo({
          url: '/pages/fill/myvolunteerList/myvolunteerList?id='+this.data.userInfo.id,
        })
      }
    },
    editUserInfo(e){
      let user = app.globalData.user;
      if(user.isSignUp == 0){
        wx.navigateTo({
          url: '/pages/fill/fillform/fillform',
        })
      }else{
        wx.navigateTo({
          url: '/pages/fill/fillform/fillform?edit=1',
        })
      }
    }
  },
  
})
